import { get, post } from './request'

// 用户相关接口
export interface UserInfo {
  id: number
  name: string
  email: string
  avatar?: string
}

export interface LoginParams {
  username: string
  password: string
}

export interface LoginResponse {
  token: string
  user: UserInfo
}

// 获取用户信息
export function getUserInfo(id: number): Promise<UserInfo> {
  return get<UserInfo>(`/user/${id}`)
}

// 用户登录
export function login(params: LoginParams): Promise<LoginResponse> {
  return post<LoginResponse>('/auth/login', params)
}

// 获取用户列表
export function getUserList(): Promise<UserInfo[]> {
  return get<UserInfo[]>('/users')
}